<!--首页--> 
<div class="cont">
  <div class="position " id="page_title"><img alt="位置图标" src="dist/images/position.png"/>风控合规>违规管理 <a ng-click="openDetail()" ng-hide="$needClientCache" title="打开新窗口查看"><i class="large External icon"></i></a></div>  
  <div class="mybackground">
    <div class="ui top attached tabular menu">
      <a class="item active" >违规单</a>
      <a class="item" ng-click="go('/fine')">罚款单</a>
    </div>
    <div class="cont_fr_top">
      <div class="cont_fr_btn">
        <div style="height: 20px;">
            <div class="fr">
                <a ng-click="export_excel(exportDefault)" style="margin-right:5px;">下载标准模板</a>
                <button class="cont_f_btn3" ngf-select="import_excel($file)" ngf-pattern="'.xls,.xlsx'" ngf-accept="'.xls,.xlsx'" ngf-max-size="20MB"><i class="ui download icon"></i>导入</button>
                <button class="cont_f_btn3"  ng-click="addShow()"><i class="ui add icon"></i>添加</button>
            </div>
        </div>
      </div>
    <div class="menus" >
      <div class="menus_con ui form">
        <div class="four fields">
          <div class="inline field">
              <label>综合查询</label>
               <input type="text" ng-model="Customer" placeholder="客户名/客户电话/客户编号" ng-keyup="$event.keyCode == 13 && ViolationsList()" style="width: 160px">
          </div>
          <div class="inline field">
            <label>业务人员</label>
            <input type="text" ng-model="salesPerson" placeholder="业务人员"  ng-keyup="$event.keyCode == 13 && ViolationsList()" style="width: 160px">
          </div>
        </div>
        <div class="four fields">
          <div class="inline field">
            <button class="clear_btn" ng-click="ViolationsList()" style="margin-left: 4em;"> 查找</button>
            <button class="clear_btn" ng-click="export_excel()"><i class="ui upload icon"></i> 导出</button>
          </div>
        </div>
      </div> 
    </div> 
  </div>
</div>
<div class="menus_table" style="top:70px;">
    <table class="ui yellow celled striped table">
      <thead>
        <tr>
          <th> 客户姓名         </th>
          <th> 合同编号         </th>
          <th> 违规原因         </th>
          <th> 违规判定时间     </th>
          <th> 违规金额(元)     </th>
          <th> 业绩归属月份(月) </th>
          <th style="text-align:center"> 操作 </th>
        </tr>
      </thead>
      <tbody ng-hide="exist">
        <tr ng-repeat="slist in new_list">
          <td><!-- {{slist.customer_name}} -->
            <div float_layer customer-id='slist.customer_id' show-name="slist.nickname"></div>
          </td>
          <td>{{slist.contract_order}}</td>
          <td>
              <div ng-switch="slist.theme">
                <div ng-switch-when="0">未知</div>
                <div ng-switch-when="1">不签订合同</div>
                <div ng-switch-when="2">暂不寄</div>
                <div ng-switch-when="3">超龄</div>
                <div ng-switch-when="4">虚假信息</div>
              </div>
          </td>
          <td> {{ slist.pub_time }}     </td>
          <td> {{ slist.fine_mount }}   </td>
          <td> {{ slist.Pattribution }} </td>
          <td style="text-align:center"> 
            <div ng-switch="slist.status">
              <div ng-switch-when="1">
                <a ng-click="editor_show(slist.fine_id)">编辑</a> 
                <a ng-click="cancel_show(slist.fine_id,slist.contract_id)">解除</a> 
              </div>
              <div ng-switch-default>
                <a ng-click="view(slist.fine_id)">查看</a> 
              </div>
            </div>
          </td>
        </tr>
      </tbody>
      <tbody ng-hide="empty">
        <tr>
          <td colspan="7" style="text-align:center;margin-top:10px;color: red" class="null_data">没有找到数据~~~</td>
        </tr>
      </tbody>
    </table> 
    <div  class="ui pagination fr menu" jspagination page-object="violationsPage" ng-show="violationsPage.pageAll > 1"  page-func="ViolationsList"   ></div>
  </div>
<!--添加違規-->
<div class="ui addShow modal">
  <i class="close icon"></i>
  <div class="header_h4"> 添加违规单 </div>
  <div class="content">
   <div class="ui form">
    <form name="frm-add" id="frm-add" >
        <div class="inline field required" id="checkHtml" >
          <label>客户姓名/客户电话</label>
          <div class="ui input" >
            <input type="hidden" name="customer" id="customerIdCheck" style="width:160px;height:32px; margin-top: -4px" />
            <div angucomplete-alt id="completion"
            placeholder="客户姓名/客户电话"
            maxlength="50"
            name="customer_id"
            pause="100" 
            selected-object="returnCustomer"
            local-data="completionCustomer"
            search-fields="nickname,phone"
            title-field="nickname"
            minlength="1"
            input-class="form-control form-control-small"
            input-changed="customer_change"
            match-class="highlight"
            style="width:160px;height:32px; display: inline-block;">
            </div> 
          </div>
        </div>
      <div class="ui segment" ng-show="Information">

        <div><b>合同记录</b></div>
        <table class="ui celled table" >
            <thead>
              <tr>
                <th>单选框</th>
                <th>合同编号</th>
                <th>服务内容</th>
                <th>订购金额(元)</th>
                <th>服务人员</th>
                <th>合同状态</th>
                <th>合同是否违规</th>
              </tr>
            </thead>
            <tbody >
            <tr ng-repeat="vlist in conceal.child" >
              <td >
                <input type="radio" name="radio"  ng-click="CheckRadio(vlist.contract_id,vlist.sales_person,vlist.sales_sector,vlist.sales_manager,vlist.sales_sub_company,vlist.start_time)" ng-checked="vlist.verify" >
              </td>
              <td>{{vlist.order_num}}</td>
              <td>{{vlist.name}}</td>
              <td style="text-align:right">{{vlist.mount}}</td>
              <td>{{vlist.nickname}}</td>
              <td>
                <div ng-switch="vlist.state"> 
                  <div ng-switch-when="-1">已取消</div>
                  <div ng-switch-when="1">服务中</div>
                  <div ng-switch-when="2">升级作废</div>
                  <div ng-switch-when="3">已完成</div>
                  <div ng-switch-when="4">签订中</div>
                  <div ng-switch-default>待审核</div>
                </div>
              </td>
              <td>
                <div ng-switch="vlist.weigui_status">
                  <div ng-switch-when="0">否</div>
                  <div ng-switch-when="11">是</div>
                  <div ng-switch-when="12">是</div>
                  <div ng-switch-when="21">否</div>
                </div>
              </td>
              </td>
            </tr>
             <tr ng-hide="empty"><td colspan="7" style="color:red;text-align:center"> 没有找到相关的信息~~~</td></tr>
            </tbody>
        </table>
        <div class="ui basic red pointing prompt label transition " ng-show="radio_err" >{{radioMsg}}</div>
        </div>
        <div class="subhead">违规信息</div>
        <div class="fields" >
          <div class="five wide field required" >
            <label class="label_fl">违规原因</label>
            <div class="ui selection dropdown" >
              <input type="hidden" name="theme" ng-model="theme_check">
              <i class="dropdown icon"></i>
              <div class="default text">违规原因</div>
              <div class="menu">
                  <div class="item" data-value="{{x.k}}"  ng-repeat="x in violationsCause" >{{x.v}}</div>
              </div>
            </div>   
          </div> 
          <div class="three wide field"></div>
          <div class="six wide field required" >
            <label class="label_fl">业绩归属时间</label>
            <div class="ui left icon input" style="width:160px;height:32px">
              <input name="attribution" datetimepicker id="attribution" format='YYYY-MM' ng-change="check_time()" ng-model="attribution" placeholder="业绩归属时间(年-月)" style="width:160px;height:32px" ng-style="myObjss">
               <i class="calendar icon"></i>
            </div>
           <div class="ui red pointing prompt label " ng-hide="text_error" ng-class='{error:isError}'>{{messageText}}</div>
          </div>
        </div>
        <div class="fields">
        	<div class="five wide field required" >
            <label class="label_fl">违规金额</label>
            <input type="text" name="fine_mount" id="fine_mount" ng-blur="check_time()" placeholder="违规金额(元)" style="width: 160px;height:32px;">
          </div>
          <div class="three wide field"></div>
          <div class="six wide field required">
            <label class="label_fl">违规判定时间</label>
            <div class="ui left icon input required" style="width:160px; height: 32px;">
              <input name="fine_pub_time" id="finePubTime" ng-model="finePubTime" datetimepicker ng-change="check_time()" format='YYYY-MM-DD' placeholder="违规判定时间" style="width:160px; height: 32px;"/>
              <i class="calendar icon"></i>
            </div>
             <div class="ui red pointing prompt label " ng-hide="text_wrong" ng-class='{wrong:isWrong}'>{{messageTexts}}</div>
          </div>
        </div>
        <div class="fields" >
          <div class="inline field ">
            <label style="margin-right: 1.4em;">备注信息</label>
            <input type="text" name="remark"  placeholder="备注信息" style="width: 645px;">
          </div> 
        </div>
      </form>
    </div>  
  </div>
  <div class="actions" style="text-align: center;">
   <div class="ui positive button">确定</div>
    <div class="ui grey button negative" ng-click="ViolationsList()">取消</div>
  </div>
</div>
<!--编辑违规单-->
<div class="ui editor_show modal">
  <i class="close icon"></i>
  <div class="header_h4"> 编辑违规单 </div>
  <div class="content">
   <div class="ui form">
    <form name="frm-save" id="frm-save" >
      <input type="hidden" name="fine_id" id="fineId">
      <input type="hidden" name="contract_id" id="contractId"> 
      <div class="ui segment" >
        <div><b>客户信息</b></div>
        <div class="ui segment">
            <div class="three fields" >
              <div class="field">
                <span>客户 :  </span>
                {{editor.customer_name}}
              </div>
              <div class="field">
                <span>业务人员 : </span>
                {{editor.user_name}}
              </div>
              <div class="field">
                <span>客户电话 : </span>
                 {{editor.phone}}
              </div>
            </div>
            <div class="three fields" >
              <div class="field" >
                <span>客户归属地 : </span>
                {{editor.location}}
              </div>
              <div class="field">
                 <span>资金(万) : </span>
                 {{editor.mount}}
              </div>
              <div class="inline field">
                 <span class="fl" style="margin-right: 3px;">客户状态 : </span>
                  <div ng-switch="editor.state" style="float:left">
                      <div ng-switch-when="0">已注册、待审核</div>
                      <div ng-switch-when="2">禁止登录用户</div>
                      <div ng-switch-when="3">无效用户</div>
                      <div ng-switch-default>正常用户</div>
                  </div>
              </div>
            </div>
          </div>
        <div><b>合同记录</b></div>
         <table class="ui celled table" >
          <thead>
            <tr>
              <th>单选框</th>
              <th>合同编号</th>
              <th>服务内容</th>
              <th>合同签订金额(元)</th>
              <th>服务人员</th>
              <th>合同状态</th>
              <th>是否违规</th>
            </tr>
          </thead>
          <tbody ng-show="save_default">
           
          <tr ng-repeat="vlist in save_conceal" >
            <td >
               <input type="radio" name="radio"  ng-click="CheckRadio(vlist.contract_id,vlist.sales_person)" ng-checked="editor.contract_id == vlist.contract_id" >
            </td>
            <td>{{vlist.order_num}}</td>
            <td>{{vlist.name}}</td>
            <td>{{vlist.mount}}</td>
            <td>{{vlist.nickname}}</td>
            <td>
              <div ng-switch="vlist.state"> 
                  <div ng-switch-when="-1">已取消</div>
                  <div ng-switch-when="1">服务中</div>
                  <div ng-switch-when="2">升级作废</div>
                  <div ng-switch-when="3">已完成</div>
                  <div ng-switch-when="4">签订中</div>
                  <div ng-switch-default>待审核</div>
                </div>
            </td>
            <td>
              <div ng-switch="vlist.weigui_status">
                <div ng-switch-when="0">否</div>
                <div ng-switch-when="11">是</div>
                <div ng-switch-when="12">是</div>
                <div ng-switch-when="21">否</div>
              </div>
            </td>
            </td>
          </tr>
          </tbody>
          <tbody ng-show="save_messges">
            <tr>
              <td colspan="7" style="text-align:center;margin-top:10px;color: red" class="null_data">没有找到数据~~~</td>
            </tr>
          </tbody>  
        </table> 
      </div>
      <div id="radio_check"></div>   
      <div><b>违规信息</b></div>
      <div class="two fields" >
        <div class="inline field required">
          <label>违规原因</label>
          <div class="ui left icon input">
          <select name='theme' class="select_text2 dropdown" ng-model="editor.theme" style="width: 160px;height: 32px" >
            <option ng-repeat="x in violationsCause" value="{{ x.k }}" ng-checked="x.k == editor.theme"> {{ x.v }} </option>
          </select>
          </div>
        </div>
        <div class="field required">
          <label class="label_fl">业绩归属</label>
          <div class="ui left icon input" style="width:160px;height:32px;margin-left:1.8em">
            <input name="performance" id="performance" datetimepicker format='YYYY-MM' ng-model="editor.Pattribution" placeholder="业绩归属(年-月)" style="width:160px;height:32px">
             <i class="calendar icon"></i>
          </div>
          <div id="check_time"></div>
        </div>

      </div>
      <div class="fields">
        <div class="five wide field required" >
          <label class="label_fl">违规金额</label>
          <input type="text" name="editor_money" ng-model="editor.fine_mount" placeholder="处罚金额(元)" style="width:160px;height:32px;margin-left:0.2em">
        </div>
        <div class="three wide field"></div>
        <div class="six wide field required">
          <label class="label_fl">违规判定时间</label>
          <div class="ui left icon input" style="width:160px;height:32px">
            <input name="pub_time" id="pubTime" ng-model="editor.pub_time" datetimepicker  format='YYYY-MM-DD' placeholder="违规判定日期" style="width:160px;height:32px"/>
            <i class="calendar icon"></i>
          </div>
        </div>
      </div>
      <div class="fields" >
        <div class="inline field ">
          <label style="margin-right: 1.4em;">备注信息</label>
          <input type="text" name="note" ng-model="editor.note"  placeholder="备注信息" style="width:644px;margin-left:0.1em">
        </div> 
      </div>
      </form>
    </div>   
  </div>
  <div class="actions" style="text-align: center;">
    <div class="ui positive button" >确定</div>
    <div class="ui grey button negative">取消</div>
  </div>
</div>
 <!--查看违规-->
<div class="ui view modal">
  <i class="close icon"></i>
  <div class="header_h4"> 违规单详情 </div>
  <div class="content">
   <div class="ui form">
    <form name="frm-view" id="frm-view" >
      <div class="ui segment" >
        <div><b>客户信息</b></div>
        <div class="ui segment">
            <div class="three fields" >
              <div class="field">
                <span>客户 :  </span>
                {{history.customer_name}}
              </div>
              <div class="field">
                <span>业务人员 : </span>
                {{history.user_name}}
              </div>
              <div class="field">
                <span>客户电话 : </span>
                 {{history.phone}}
              </div>
            </div>
            <div class="three fields" >
              <div class="field" >
                <span>客户归属地 : </span>
                {{history.location}}
              </div>
              <div class="field">
                 <span>资金(万) : </span>
                 {{history.mount}}
              </div>
              <div class="inline field">
                <span class="fl" style="margin-right: 3px;">客户状态 : </span>
                <div ng-switch="history.state" style="float:left">
                    <div ng-switch-when="0">已注册、待审核</div>
                    <div ng-switch-when="2">禁止登录用户</div>
                    <div ng-switch-when="3">无效用户</div>
                    <div ng-switch-default>正常用户</div>
                </div>
              </div>
            </div>
          </div>
        <div><b>合同记录</b></div>
         <table class="ui celled table" >
          <tbody >
           <tr>
            <td>单选框</td>
            <td>合同编号</td>
            <td>服务内容</td>
            <td>合同签订金额(元)</td>
            <td>服务人员</td>
            <td>合同状态</td>
            <td>合同是否违规</td>
          </tr>
          <tr >
            <td><input type="radio" name="radio" checked="checked" ></td>
            <td>{{history.contract_order}}</td>
            <td>{{history.name}}</td>
            <td style="text-align:right">{{history.contract_mount}}</td>
            <td>{{history.user_name}}</td>
            <td>
              <div ng-switch="history.contract_state"> 
                <div ng-switch-when="-1">已取消</div>
                <div ng-switch-when="1">服务中</div>
                <div ng-switch-when="2">升级作废</div>
                <div ng-switch-when="3">已完成</div>
                <div ng-switch-default>待审核</div>
              </div>
            </td>
            <td>
              <div ng-switch="history.weigui_status">
                <div ng-switch-when="0">否</div>
                <div ng-switch-when="11">是</div>
                <div ng-switch-when="12">是</div>
                <div ng-switch-when="21">否</div>
              </div>
            </td>
            </td>
          </tr>
          </tbody>
        </table> 
      </div>  
      <div><b>违规信息</b></div>
      <div class="two fields" >
        <div class="inline field ">
          <span class="fl" style="margin-right: 3px;"><b>违规原因 : </b></span>
          <div ng-switch=" history.theme" style="float:left">
            <div ng-switch-when="0">未知</div>
            <div ng-switch-when="2">暂不寄</div>
            <div ng-switch-when="3">超龄</div>
            <div ng-switch-when="4">虚假信息</div>
            <div ng-switch-default>不签订合同</div>
          </div>
        </div>
        <div class="inline field ">
          <label>业绩归属 ：</label>
          <div class="ui left icon input">
            {{ history.Pattribution }}
          </div>
        </div>
      </div>
      <div class="two fields">
        <div class="inline field " >
          <label>违规金额：</label>
          {{ history.fine_mount }} 元
        </div>
        <div class="inline field ">
          <label>判定日期：</label>
          <div class="ui left icon input" >
            {{ history.pub_time }}
          </div>
        </div>
      </div>
      <div class="fields" >
        <div class="inline field ">
          <label style="margin-right: 1.4em;">备注信息：</label>
          {{ history.note }}
        </div> 
      </div>
      </form>
    </div>   
  </div>
  <div class="actions" style="text-align: center;">
    <div class="ui positive button">关闭</div>
  </div>
</div>

<!--取消提醒-->
<div class="ui large modal remind" style="text-align: center;">
    <div class="header">取消违规单</div>
    <div class="content">
        <i class="huge blue help circle icon"></i>
        <p style="padding-top: 15px;">确认取消该违规单及相关合同的信息吗?</p>
    </div>
    <div class="actions" style="text-align: center;">
      <div class="ui positive button" ng-click="cancel()" >确定</div>
      <div class="ui grey button negative">取消</div>
    </div>
</div>

<!--成功-->
<div class="ui small modal modal1 time" style="text-align: center;">
    <div class="header">提示</div>
    <div class="content">
        <i class="huge green check circle outline icon"></i>
        <p style="padding-top: 15px;">{{Msg}}成功</p>
    </div>
</div>
<!--失败-->
<div class="ui modal modal2 time" style="text-align: center;">
    <div class="header">提示</div>
    <div class="content">
        <i class="huge red warning outline icon"></i>
        <p style="padding-top: 15px;">{{Msg}}失败</p>
    </div>
</div>

<!--导入操作结果-->
<div class="ui small error_shw modal " style="text-align: center;">
    <div class="header_h4">系统提示</div>
    <div class="content">
        <table class="ui table" border="1">
          <thead>
            <tr><th style="text-align:center">标题</th><th style="text-align:center" colspan="2">提示信息</th></tr>
          </thead>
          <tbody>
            <tr> 
              <td style="text-align:center"> 上传数据共 <span style="color:red"> ( {{ statistical.sum }} ) </span> 条</td>
              <td style="text-align:center"> 更新有效数据共 <span style="color:red"> ( {{ statistical.successful }} ) </span> 条</td>
              <td style="text-align:center"> 重复数据共 <span style="color:red"> (  {{ statistical.repeat }}  ) </span> 条</td>
            </tr>
            <tr> 
              <td style="text-align:center"> 需重新审核错误信息共 <span style="color:red"> ( {{ statistical.matching }} ) </span> 条</td>
              <td style="text-align:center" colspan="2">  <span style="color:red"> {{ invalid }} </span> </td>
            </tr>
          </tbody>
        </table>
        
    </div>
    <div class="actions" style="text-align: center;">
      <div class="ui positive button">确定</div>
    </div>
</div>
<script type="text/javascript">

  $( function(){
    $.fn.form.settings.rules.check_hide = function() {
      var isValid = true;
      var customerid = $('#frm-add input[name="customer"]').val();
      if(customerid == '-1')
          isValid = false;
      else
          isValid = true;
      return isValid;
    };
  /*********************************************/
    $('#frm-add').form({
      on: 'blur',
      inline : true,
      fields: {
        customer: {
          rules: [
            {
              type   : 'empty',
              prompt : '客户不为空!!!'
            },{
              type   : 'check_hide',
              prompt : '客户不存在!!!'
            }
          ]
        },
        fine_mount: {
          rules: [
            {
              type   : 'empty',
              prompt : '处罚金额不能空!!!'
            },{
              type   : 'number',
              prompt : '只能是数字,不能包含特殊字符!!!'
            },{
              type   : 'integer[1..]',
              prompt : '必须是大于1的有效数字!!!'
            }
          ]
        },
        theme: {
          rules: [
            {
              type   : 'empty',
              prompt : '违规原因不能为空!!!'
            }
          ]
        },

      }
    }); 
  /*********************************************/ 
    setTimeout(function() {
      registerHiddenBlur('customerIdCheck', 'completion_value');
      }, 200);  
    });
  /********************************/
    $( function(){
        $('#frm-save').form({
        on: 'blur',
        inline : true,
        fields: {
          theme: {
            rules: [
              {
                type   : 'empty',
                prompt : '违规原因不能为空!!!'
              }
            ]
          },
          performance: {
            rules: [
              {
                type   : 'empty',
                 prompt : '归属业绩不能空!!!'
              }
            ]
          }, 
          pub_time: {
            rules: [
              {
                type   : 'empty',
                prompt : '发布时间不能为空!!!'
              }
            ]
          },
          editor_money: {
            rules: [
              {
                type   : 'empty',
                prompt : '处罚金额不能空!!!'
              },{
                type   : 'number',
                prompt : '必须是数字!!!'
              }
            ]
          },
        }
    });  
  });


/*******************************/
 //延时登记所有需要blur验证的hidden input（可视的input开始时未生成）

//登记所有需要blur验证的hidden input，振东和张叶商量放在公共js中供大家调用
    //hiddenID: hidden input的id
    //visibleID: hidden input对应的可视input id，通常由输入组件运行时动态创建。如ConMsg动态生成ConMsg_value
  function registerHiddenBlur(hiddenID, visibleID) {
      $('#' + visibleID).blur(function() {
          //延时触发blur，目的是让hidden input先于blur被赋值
          setTimeout(function() {
              $('#' + hiddenID).trigger('blur');
          }, 100);
      });
  }
</script>